package ute.mvc.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name="class")
public class MyClass implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 590084967802132440L;
	@NotEmpty
	@Id
	@Column (length = 20)
	private String classId;
	@NotEmpty
	@Column (length = 100, nullable = false)
	private String className;
	
	@JsonIgnore
	@ManyToOne
	@JoinColumn (name="openCourse")
	private OpenCourse openCourse;
	
	@JsonIgnore
	@ManyToMany
	@JoinTable (name = "class_student", joinColumns = @JoinColumn(name="classId"),
				inverseJoinColumns = @JoinColumn(name="studentId"))
	private Collection<User> listStudent = new ArrayList<User>();
	
	@JsonIgnore
	@ManyToMany (mappedBy = "listClass")
	private Collection<Assignment> listAssignment = new ArrayList<Assignment>();
	
	//Vinh
	@JsonIgnore
	@ManyToMany(mappedBy = "listClass")
	private Collection<TestAndQuizz> listTest = new ArrayList<TestAndQuizz>();

	public String getClassId() {
		return classId;
	}

	public void setClassId(String classId) {
		this.classId = classId;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public OpenCourse getOpenCourse() {
		return openCourse;
	}

	public void setOpenCourse(OpenCourse openCourse) {
		this.openCourse = openCourse;
	}

	public Collection<User> getListStudent() {
		return listStudent;
	}

	public void setListStudent(Collection<User> listStudent) {
		this.listStudent = listStudent;
	}
}
